// get the client
const mysql = require('mysql');

// Create the connection pool. The pool-specific settings are the defaults
const pool = mysql.createPool({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'three',
});

const query = (sql) => {
    return new Promise((resolve, reject) => {
        pool.getConnection(function (err, conn) {
            // Do something with the connection
            conn.query(sql, (err, res) => {
                resolve(res)
            });
            // Don't forget to release the connection when finished!
            pool.releaseConnection(conn);
        });
    })
}

module.exports = query